<template>
  <div>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      @change="handleTableChange"
    >
      <span slot="actionName">
        <a-button size="small" @click="openCreatModel()" type="primary" icon="plus">新增</a-button>
      </span>
      <span slot="status" slot-scope="text, record">
        <span v-if="text != '3'">{{ status[text] }}</span>
        <a v-else @click="handleLookAudit(record, '审批详情')">{{ status[text] }}(查看原因)</a>
      </span>
      <span slot="action" slot-scope="text, record">
        <a @click="handleDetail(record, '')">查看</a>
        <!-- <template v-if="role == '1'"
          ><a-divider type="vertical" />
          <a-popconfirm
            style="margin-left: 8px"
            :disabled="disableSubmit"
            title="确定归档?"
            @confirm="handleSum(record)"
          >
            <a>归档</a>
          </a-popconfirm>
        </template> -->
      </span>
    </a-table>
    <ysModel :role="role" @load="loadData()" ref="modalForm"></ysModel>
    <CheckAndEditModel ref="auditView"></CheckAndEditModel>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import columns from '../indexColumns'
import ysModel from './ysModel.vue'
import { postAction } from '@/api/manage'
import CheckAndEditModel from '../CheckAndEditModel.vue'
export default {
  components: { ysModel, CheckAndEditModel },
  mixins: [JeecgListMixin],
  props: ['role'],
  data() {
    return {
      // 表头
      columns: columns(this),
      dataSource: [],
      status: {
        0: '待提交',
        1: '待审核',
        2: '已通过',
        3: '已驳回',
      },
      url: {
        list: '/performcheck/checkDeptInfo/queryPendingList',
        sum: '/performcheck/checkDeptInfo/auditSum',
      },
      disableMixinCreated: true,
    }
  },
  mounted() {
    this.handleModelSubmit({
      auditFlag: '1',
    })
  },
  methods: {
    handleLookAudit(record, name) {
      this.$refs.auditView.check(record)
      this.$refs.auditView.title = name
      // this.$refs.modalForm.disableSubmit = true
    },
    // 重新加载
    handleModelSubmit(params) {
      this.queryParam = params
      this.loadData(1)
    },
    handleSum(record) {
      postAction(this.url.sum, { id: record.id }).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
      })
    },
  },
}
</script>

<style>
</style>